<?php

namespace App\Http\Controllers\File;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class FileController extends Controller
{
    //
    public function index()
    {
        return view('file/file');
    }

    public function showUploadFile(Request $request) {
        $file = $request->file('image');
        // //Display File Name
        $filename = $file->getClientOriginalName();
        // echo '<br>';
     
        // //Display File Extension
        // echo 'File Extension: '.$file->getClientOriginalExtension();
        // echo '<br>';
     
        // //Display File Real Path
        // echo 'File Real Path: '.$file->getRealPath();
        // echo '<br>';
     
        // //Display File Size
        // echo 'File Size: '.$file->getSize();
        // echo '<br>';
     
        // //Display File Mime Type
        // echo 'File Mime Type: '.$file->getMimeType();
     
        //Move Uploaded File
        $destinationPath = 'uploads';
        // foreach($files as $file){
            $file->move($destinationPath,$filename);
        // }
        // return response()->json([
        //     'ok'=>'ok',
        // ]);
        
        
        return response()->json([
            'status' => 'success',
            'data-id' => '123456',
            'url'=> 'http://localhost/uploads/'.$filename,
            'msg' => 'fuck it'
        ], 200);
     }
}
